package com.uyayo.oms.config;

import com.jagregory.shiro.freemarker.ShiroTags;
import com.uyayo.oms.system.freemarker.DictionaryDirective;
import freemarker.template.Configuration;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@org.springframework.context.annotation.Configuration
public class FreeMarkerConfig implements InitializingBean{

	@Autowired
    private Configuration configuration;

	@Override
	public void afterPropertiesSet() {
		// 加上这句后，可以在页面上使用shiro标签
		configuration.setSharedVariable("shiro", new ShiroTags());
		configuration.setSharedVariable("dictionary", dictionaryDirective());
		}

		@Bean
		public DictionaryDirective dictionaryDirective(){
			return new DictionaryDirective();
		}
	}